package com.luckeys.controller;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.luckeys.contants.CommonContans;
import com.luckeys.service.ActivityTypeService;
import com.luckeys.vo.ActivityTypeVO;

@RestController
@RequestMapping(value = "/activityType", method = RequestMethod.POST)
public class ActivityTypeController {

	@Autowired
	private ActivityTypeService activityTypeService;


	@RequestMapping(value = "/queryPage", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryActivityTypePage(@RequestBody ActivityTypeVO activityType) {
		ModelMap resultMap = new ModelMap();
		resultMap.put(CommonContans.STRUTS_DATA,
				activityTypeService.queryActivityTypePage(activityType));
		resultMap
				.put(CommonContans.STRUTS_RESULT, CommonContans.STRUTS_SUCCESS);
		return resultMap;
	}
	
	@RequestMapping(value = "/queryList", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryListActivityType(@RequestBody ActivityTypeVO activityType) {
		ModelMap resultMap = new ModelMap();
		resultMap.put(CommonContans.STRUTS_DATA,
				activityTypeService.queryActivityTypeList(activityType));
		resultMap
		.put(CommonContans.STRUTS_RESULT, CommonContans.STRUTS_SUCCESS);
		return resultMap;
	}

	@RequestMapping(value = "/addActivityType", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap addActivityType(@RequestBody ActivityTypeVO activityType) {
		ModelMap resultMap = new ModelMap();
		activityType.setActivityTypeUuid(UUID.randomUUID().toString());
		resultMap.put(CommonContans.STRUTS_DATA, activityTypeService.addActivityType(activityType));
		resultMap
				.put(CommonContans.STRUTS_RESULT, CommonContans.STRUTS_SUCCESS);
		return resultMap;
	}

	@RequestMapping(value = "/deleteActivityType", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap deleteActivityType(String activityTypeUuid) {
		ModelMap resultMap = new ModelMap();
		resultMap.put(CommonContans.STRUTS_DATA, activityTypeService.deleteActivityType(activityTypeUuid));
		resultMap
				.put(CommonContans.STRUTS_RESULT, CommonContans.STRUTS_SUCCESS);
		return resultMap;
	}
	
	@RequestMapping(value = "/queryActivityTypeById", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap queryActivityTypeById(String activityTypeUuid) {
		ModelMap resultMap = new ModelMap();
		ActivityTypeVO activityType = activityTypeService.queryActivityTypeById(activityTypeUuid);
		resultMap.put(CommonContans.STRUTS_DATA, activityType);
		resultMap
				.put(CommonContans.STRUTS_RESULT, CommonContans.STRUTS_SUCCESS);
		return resultMap;
	}
	
	@RequestMapping(value = "/updateActivityType", consumes = "application/json", produces = "application/json")
	@ResponseBody
	public ModelMap updateActivityType(@RequestBody ActivityTypeVO activityType) {
		ModelMap resultMap = new ModelMap();
		resultMap.put(CommonContans.STRUTS_DATA, activityTypeService.updateActivityType(activityType));
		resultMap
				.put(CommonContans.STRUTS_RESULT, CommonContans.STRUTS_SUCCESS);
		return resultMap;
	}
}
